package com.mp;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mp.beans.MyListener;

@RestController
/*@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages="com.mp")*/
@SpringBootApplication
@ConfigurationProperties(prefix="spring.kafka")
@EnableEurekaClient
public class StartSpring {
	
	@Resource
	private KafkaTemplate<?, String> kafkaTemplate;
	
	@RequestMapping("/kafka/{message}")
	public String helloBoot(@PathVariable String message) {
		System.out.println(message);
		kafkaTemplate.send("testTopic", message);
		return "thanks for everyone";
	}

	public static void main(String[] args) {
		//System.setProperty("spring.config.location", "classpath:/com/mp/config/myconfig.yml");
		//System.setProperty("spring.config.name", "myconfig");
		//System.out.println(System.getProperty("application-default.properties"));
		//System.setProperty("spring.profiles.active", "dev2");
		SpringApplication.run(StartSpring.class, args);
	}

}
